<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div>
        <button onclick="clickFn()" ondblclick="dblclickFn()">点击</button>
    </div>
    <script>
        //练习:单击时触发单击事件, 双击时只触发双击事件
        let timer = null
        //单机事件
        function clickFn() {
            clearTimeout(timer)
            timer = setTimeout(function (){
                alert('单机2班');
            },500)
        }
        //双击事件
        function dblclickFn() {
            clearTimeout(timer)
            alert('双击4班');
        }
        </script>
</body>
</html>